package com.tedu.egweibo.common.result;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    //  统一返回类型
    private Integer status;
    private Object data;
    private String message;


    public JsonResult(StatusCode statusCode){
        this.status = statusCode.getStatus();
        this.message = statusCode.getMessage();
    }
    public JsonResult(StatusCode statusCode,Object data){
        this(statusCode);
        this.data = data;
    }

    // 静态方法
    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult success(){
        return success(null);
    }

}
